package com.mingloucct.payment_ws.service.impl;

import com.mingloucct.payment_ws.dao.INeishenDao;
import com.mingloucct.payment_ws.entity.Neishen;
import com.mingloucct.payment_ws.entity.ShenHeInfo;
import com.mingloucct.payment_ws.service.INeishenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

@Service
public class NeishenService implements INeishenService {
    @Autowired
    private INeishenDao iNeishenDao;

    @Override
    public List<Neishen> readNeishen(@RequestParam String quary){
        List<Neishen> neishen = iNeishenDao.readNeishen(quary);
        return neishen;
    }
    @Override
    public List<Neishen> readWaishen(@RequestParam String quary){
        List<Neishen> neishen = iNeishenDao.readWaishen(quary);
        return neishen;
    }
    @Override
    public List<Neishen> readFangkuan(@RequestParam String quary){
        List<Neishen> fangkuan = iNeishenDao.readFangkuan(quary);
        return fangkuan;
    }
    @Override
    public  void updateByID(@RequestParam ("customID") String customID,
                    @RequestParam("date") String date,
                    @RequestParam("CustomName") String CustomName,
                    @RequestParam("Province") String Province,
                    @RequestParam("City") String City,
                    @RequestParam("Address") String Address,
                    @RequestParam("PostNum") String PostNum
    ){
        iNeishenDao.updateByID(customID,date,CustomName,Province,City,Address,PostNum);
    }
    @Override
    public void updateShenheByID(@RequestParam("CustomID") String customID,
                          @RequestParam("CarPrice") String CarPrice,
                          @RequestParam("Prepay") String Prepay,
                          @RequestParam("Dai_kuan_jin_e") String Dai_kuan_jin_e,
                          @RequestParam("Zong_he_li_lv") String Zong_he_li_lv,
                          @RequestParam("Dai_kuan_nian_shu") String Dai_kuan_nian_shu,
                          @RequestParam("Yue_gong") String Yue_gong,
                          @RequestParam("Dai_kuan_lei_xing") String Dai_kuan_lei_xing,
                          @RequestParam("Marriage") String Marriage
    ){
        iNeishenDao.updateShenheByID(customID,CarPrice,Prepay,Dai_kuan_jin_e,Zong_he_li_lv,Dai_kuan_nian_shu,Yue_gong,Dai_kuan_lei_xing,Marriage);
    }
    @Override
    public void deleteByID(@RequestParam("customID") String customID){
        iNeishenDao.deleteByID(customID);
    }
    @Override
    public void changeByID(@RequestParam("customID") String customID,@RequestParam("amount") String amount){
        iNeishenDao.changeByID(customID,amount);
    }
    @Override
    public String upLoadFile(MultipartFile upload,String CustomID,int Type){
        return iNeishenDao.upLoadFile(upload,CustomID,Type);
    }
    @Override
    public void uploadToDB(String CustomID,String url,String Type,String filename){
        iNeishenDao.uploadToDB(CustomID,url, Type, filename);;
    }

    @Override
    public ShenHeInfo selectShenHeInfo(String CustomID) {
        return iNeishenDao.selectShenHeInfo(CustomID);
    }

    @Override
    public void changeStatus(String customID) {
        iNeishenDao.changeStatus(customID);
    }
}
